Component({
  data: {
    active:0,
    list: [
			{
				icon: 'shop-o',
				text: '首页',
				url: '/pages/index/index'
			},
			{
				icon: 'orders-o',
				text: '订单',
				url: '/pages/order/order'
      },
      {
				icon: 'manager-o',
				text: '我的',
				url: '/pages/mine/mine'
			}
		]
  },
  methods: {
    onTabBarChange(event){
      this.setData({ active: event.detail });
			wx.switchTab({
				url: this.data.list[event.detail].url
			});
    },
    init() {//结束时调用函数
			const page = getCurrentPages().pop();
			this.setData({
				active: this.data.list.findIndex(item => item.url === `/${page.route}`)
			});
		}
  }
})